/* See LICENSE file for copyright and license details. */

/* appearance */
// the age of terminus is over
//static const char dmenufont[] = "Terminus:pixelsize=28:style=Bold";
static const char dmenufont[] = "Ubuntu Mono:size=18";
static const char dmenuheight[] = "42";
static const char *fonts[] = {
	"Ubuntu Mono:size=18",
	"FontAwesome:size=18",
	"M+ 2p medium:size=18",
};

/* ignore these (except borders), handled below */

// use colors[0][0]/colors[0][2]/colors[0][1] instead
//static const char normbordercolor[] = "#444444";
//static const char normbgcolor[]     = "#222222";
//static const char normfgcolor[]     = "#bbbbbb";
// use colors[1][0]/colors[1][2]/colors[1][1] instead
//static const char selbordercolor[]  = "#005577";
//static const char selbgcolor[]      = "#005577";
//static const char selfgcolor[]      = "#eeeeee";

/* settings */
static const unsigned int borderpx  = 6;        /* border pixel of windows */
static const unsigned int gappx     = 18;       /* gap pixel between windows */
static const unsigned int barsize   = 18;       /* height of bar */
static const unsigned int snap      = 16;       /* snap pixel */
static const int showbar            = 1;        /* 0 means no bar */
static const int topbar             = 0;        /* 0 means bottom bar */

/* color handling */
#define NUMCOLORS         6
#define MAXC              3
//                colors[NUMCOLORS][MAXCOLORS][8]
static const char colors[NUMCOLORS][MAXC][8] = {
  // border   foreground background
  //{ "#000033", "#dddddd", "#000033" },  // normal
  //{ "#000044", "#ffffff", "#000044" },  // selected
  //{ "#ff0000", "#000000", "#ffff00" },  // urgent/warning  (black on yellow)
  //{ "#ff0000", "#ffffff", "#ff0000" },  // error (white on red)
// solid style
/*
  { "#300020", "#dddddd", "#300020" },  // normal
  { "#600040", "#ffffff", "#600040" },  // selected
  { "#ff0000", "#000000", "#ffff00" },  // urgent/warning  (black on yellow)
  { "#ff0000", "#ffffff", "#ff0000" },  // error (white on red)
  { "#ff0000", "#80005d", "#300015" },  // song
  { "#ff0000", "#ffffff", "#300015" },  // user
*/
// old colors
/*
{ "#300426", "#dddddd", "#300426" },  // normal
{ "#b0008d", "#ff00aa", "#300426" },  // selected
{ "#ff0000", "#dddddd", "#bb0040" },  // urgent/warning
{ "#ff0000", "#dddddd", "#90006d" },  // error
{ "#ff0000", "#dddddd", "#90006d" },  // song
{ "#ff0000", "#dddddd", "#006466" },  // user
*/
// flat style
  { "#300426", "#dddddd", "#081620" },  // normal
  { "#4793cc", "#4793cc", "#081620" },  // selected
  { "#ff0000", "#dddddd", "#bb0040" },  // urgent/warning
  { "#ff0000", "#dddddd", "#184457" },  // error
  { "#ff0000", "#dddddd", "#184457" },  // song
  { "#ff0000", "#dddddd", "#4793cc" },  // user
  // add more here
};

/* tagging */
//static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const char *tags[] = { "一","二", "三", "四", "五", "六", "七", "八", "九" };

static const Rule rules[] = {
	/* xprop(1):
	 *	WM_CLASS(STRING) = instance, class
	 *	WM_NAME(STRING) = title
	 */
	// TUI
	/* class           instance         title       tags mask  isfloating  monitor */
	{ "st-256color",   "st-256color",   "todoi",    0,         1,           0 },
	{ "remind-st",     "remind-st",     NULL,       0,         1,           0 },
	{ "cal-st",        "cal-st",        NULL,       0,         1,           0 },
	{ "cmus-st",       "cmus-st",       NULL,       1 << 8,    0,          -1 },
	// GUI
	/* class                    instance                   title                               tags mask  isfloating  monitor */
	{ "Firefox",                NULL,                      NULL,                               0,         0,          -1 },
	{ "Xfe",                    NULL,                      NULL,                               0,         1,          -1 },
	{ "mpv",                    NULL,                      "mpv",                              0,         1,          -1 },
	{ "feh",                    NULL,                      NULL,                               0,         1,          -1 },
	{ "ksnip",                  NULL,                      NULL,                               0,         1,          -1 },
	{ "Steam",                  NULL,                      NULL,                               0,         1,          -1 },
	{ "Virt-manager",           "virt-manager",            "Virtual Machine Manager",          1 << 7,    0,           0 },
	{ "Virt-manager",           "virt-manager",            "almalinux9 on QEMU/KVM",           1 << 2,    0,           1 },
	{ "qtfm",                   "qtfm",                    NULL,                               0,         1,          -1 },
	{ "Pcmanfm",                "pcmanfm",                 NULL,                               0,         1,          -1 },
	{ "dolphin",                "dolphin",                 NULL,                               0,         1,          -1 },
	{ "Sxiv",                   "sxiv",                    NULL,                               0,         1,          -1 },
	{ "cmus-rg",                "cmus-rg",                 NULL,                               0,         1,           0 },
	{ "Rt",                     "rt",                      NULL,                               0,         1,          -1 },
	{ "ffplay",                 "ffplay",                  NULL,                               0,         1,          -1 },
	{ "Vivado",                 "Vivado",                  NULL,                               0,         0,           0 },
	{ "quartus",                "quartus",                 NULL,                               0,         0,           0 },
	{ "qutebrowser",            "qutebrowser",             NULL,                               1 << 0,    0,           1 },
	{ "Gimp",                   NULL,                      NULL,                               1 << 2,    1,          -1 },
	{ "krita",                  "krita",                   NULL,                               1 << 2,    0,           1 },
	{ "jetbrains-idea-ce",      NULL,                      NULL,                               1 << 2,    0,          -1 },
	{ "Tor Browser",            NULL,                      NULL,                               1 << 2,    1,          -1 },
	{ "qBittorrent",            "qbittorrent",             NULL,                               1 << 6,    0,           0 },
	{ "Mumble",                 "mumble",                  NULL,                               1 << 7,    0,           0 },
	{ "Chromium",               "chromium",                NULL,                               1 << 7,    0,          -1 },
	{ "Wire",                   "wire",                    NULL,                               1 << 8,    0,           0 },
	{ "Element",                "element",                 NULL,                               1 << 8,    0,           0 },
	{ "TelegramDesktop",        "telegram-desktop",        NULL,                               1 << 8,    0,           0 },
	{ "Thunderbird",            "Mail",                    NULL,                               1 << 8,    0,           0 },
	{ "Code - OSS",             "code - oss",              NULL,                               1 << 2,    0,          -1 },
	// game
	/* class                            instance                          title                    tags mask  isfloating  monitor */
	{ "Wine",                           NULL,                             "Adobe Flash Player 32", 0,         1,          -1 },
	{ "osu!",                           NULL,                             "osu!lazer",             0,         1,          -1 },
	{ "touhou-thing",                   "touhou-thing",                   NULL,                    0,         1,          -1 },
	{ "Civ6Sub",                        "Civ6Sub",                        NULL,                    0,         1,          -1 },
	{ "steam_proton",                   "steam_proton",                   NULL,                    0,         1,          -1 },
	{ "Wine",                           "th123.exe",                      NULL,                    0,         1,          -1 },
	{ "Lutris",                         "lutris",                         NULL,                    1 << 7,    0,           0 },
	{ "幻想人形演舞-ユメノカケラ-.exe", "幻想人形演舞-ユメノカケラ-.exe", NULL,                    0,         1,          -1 },
	{ "Vsim",                           "vsim",                           NULL,                    1 << 1,    0,           0 },
};

/* layout(s) */
static const float mfact     = 0.6; /* factor of master area size [0.05..0.95] */
static const int nmaster     = 1;    /* number of clients in master area */
static const int resizehints = 0;    /* 1 means respect size hints in tiled resizals */

static const Layout layouts[] = {
	/* symbol     arrange function */
	{ "||=",      tile },    /* first entry is default */
	{ "[[]",      NULL },    /* no layout function means floating behavior */
	{ "[M]",      monocle },
};

/* key definitions */
#define MODKEY Mod1Mask
#define WINKEY Mod4Mask
#define TAGKEYS(KEY,TAG) \
	{ MODKEY,                       KEY,      view,           {.ui = 1 << TAG} }, \
	{ MODKEY|ControlMask,           KEY,      toggleview,     {.ui = 1 << TAG} }, \
	{ MODKEY|ShiftMask,             KEY,      tag,            {.ui = 1 << TAG} }, \
	{ MODKEY|ControlMask|ShiftMask, KEY,      toggletag,      {.ui = 1 << TAG} },

/* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }

/* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
//static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
static const char *dmenucmd[]           = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-h", dmenuheight, "-nb", colors[0][2], "-nf", colors[0][1], "-sb", colors[1][2], "-sf", colors[1][1], NULL };
static const char *roficmd[]            = { "rofi", "-show", "run", NULL };
static const char *roficmdalt[]         = { "rofi", "-show", "drun", NULL };
static const char *termcmd[]            = { "st", NULL };
static const char *lockercmd[]          = { "slock", NULL };
static const char *webbrowsercmd[]      = { "qutebrowser", "strlst.myogaya.jp", NULL };
static const char *filebrowsercmd[]     = { "dolphin", NULL };
static const char *termfilebrowsercmd[] = { "st", "rover", NULL };
static const char *musicplayercmd[]     = { "st", "-c", "cmus-st", "-n", "cmus-st", "cmus", NULL };
static const char *calcmd[]             = { "st", "-c", "cal-st", "-n", "cal-st", "-g", "=20x9+1680-64", "cali", NULL };
static const char *taskmgrcmd[]         = { "st", "htop", NULL };
static const char *remindcmd[]          = { "remind", NULL };
static const char *musicartcmd[]        = { "cmus-rg", NULL };

#include "movestack.c"
static Key keys[] = {
	/* modifier                     key        function        argument */
	//{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd   } },
	{ MODKEY,                       XK_p,      spawn,          {.v = roficmd    } },
	{ MODKEY|ShiftMask,             XK_p,      spawn,          {.v = roficmdalt } },
	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd    } },
	{ MODKEY|ShiftMask,             XK_t,      spawn,          {.v = termcmd    } },
	/* windows shortcuts LMAO */
	{ WINKEY,                       XK_t,      spawn,          {.v = termcmd    } },
	//{ MODKEY|ShiftMask,             XK_s,      spawn,          {.v = webbrowsercmd } },
	//{ WINKEY,                       XK_s,      spawn,          {.v = webbrowsercmd } },
	{ MODKEY|ShiftMask,             XK_e,      spawn,          {.v = filebrowsercmd } },
	{ WINKEY,                       XK_e,      spawn,          {.v = filebrowsercmd } },
	{ MODKEY|ShiftMask,             XK_r,      spawn,          {.v = remindcmd } },
	{ WINKEY,                       XK_r,      spawn,          {.v = remindcmd } },
	{ MODKEY|ShiftMask,             XK_l,      spawn,          {.v = lockercmd } },
	{ WINKEY,                       XK_l,      spawn,          {.v = lockercmd } },
	{ MODKEY|ShiftMask,             XK_y,      spawn,          {.v = musicplayercmd } },
	{ WINKEY,                       XK_y,      spawn,          {.v = musicplayercmd } },
	{ MODKEY|ShiftMask,             XK_u,      spawn,          {.v = musicartcmd } },
	{ WINKEY,                       XK_u,      spawn,          {.v = musicartcmd } },
	{ MODKEY|ShiftMask,             XK_i,      spawn,          {.v = calcmd } },
	{ ControlMask|ShiftMask,        XK_Escape, spawn,          {.v = taskmgrcmd } },
	{ MODKEY,                       XK_b,      togglebar,      {0} },
	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
	{ MODKEY|ShiftMask,             XK_j,      movestack,      {.i = +1 } },
	{ MODKEY|ShiftMask,             XK_k,      movestack,      {.i = -1 } },
	{ MODKEY,                       XK_i,      incnmaster,     {.i = +1 } },
	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
	{ MODKEY,                       XK_Return, zoom,           {0} },
	{ MODKEY,                       XK_Tab,    view,           {0} },
	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
	{ MODKEY|ShiftMask,             XK_x,      killunsel,      {0} },
	{ MODKEY|ShiftMask,             XK_x,      killunsel,      {0} },
	{ MODKEY,                       XK_t,      setlayout,      {.v = &layouts[0]} },
	{ MODKEY,                       XK_f,      setlayout,      {.v = &layouts[1]} },
	{ MODKEY,                       XK_m,      setlayout,      {.v = &layouts[2]} },
	{ MODKEY,                       XK_space,  setlayout,      {0} },
	{ MODKEY|ShiftMask,             XK_space,  togglefloating, {0} },
	{ MODKEY,                       XK_s,      togglesticky,   {0} },
	{ MODKEY,                       XK_0,      view,           {.ui = ~0 } },
	{ MODKEY|ShiftMask,             XK_0,      tag,            {.ui = ~0 } },
	{ MODKEY,                       XK_comma,  focusmon,       {.i = -1 } },
	{ MODKEY,                       XK_period, focusmon,       {.i = +1 } },
	{ MODKEY|ShiftMask,             XK_comma,  tagmon,         {.i = -1 } },
	{ MODKEY|ShiftMask,             XK_period, tagmon,         {.i = +1 } },
	{ MODKEY|ShiftMask,             XK_minus,  setgaps,        {.i = -8 } },
	{ MODKEY|ShiftMask,             XK_plus,   setgaps,        {.i = +8 } },
	TAGKEYS(                        XK_1,                      0)
	TAGKEYS(                        XK_2,                      1)
	TAGKEYS(                        XK_3,                      2)
	TAGKEYS(                        XK_4,                      3)
	TAGKEYS(                        XK_5,                      4)
	TAGKEYS(                        XK_6,                      5)
	TAGKEYS(                        XK_7,                      6)
	TAGKEYS(                        XK_8,                      7)
	TAGKEYS(                        XK_9,                      8)
	{ MODKEY|ShiftMask,             XK_q,      quit,           {0} },
};

/* button definitions */
/* click can be ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
static Button buttons[] = {
	/* click                event mask      button          function        argument */
	{ ClkLtSymbol,          0,              Button1,        setlayout,      {0} },
	{ ClkLtSymbol,          0,              Button3,        setlayout,      {.v = &layouts[2]} },
	{ ClkWinTitle,          0,              Button2,        zoom,           {0} },
	{ ClkStatusText,        0,              Button2,        spawn,          {.v = termcmd } },
	{ ClkClientWin,         MODKEY,         Button1,        movemouse,      {0} },
	{ ClkClientWin,         MODKEY,         Button2,        togglefloating, {0} },
	{ ClkClientWin,         MODKEY,         Button3,        resizemouse,    {0} },
	{ ClkTagBar,            0,              Button1,        view,           {0} },
	{ ClkTagBar,            0,              Button3,        toggleview,     {0} },
	{ ClkTagBar,            MODKEY,         Button1,        tag,            {0} },
	{ ClkTagBar,            MODKEY,         Button3,        toggletag,      {0} },
};

